package com.rentplant;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.itemjudge;
import com.rentplant.service.impl.itemJudgeServiceImp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Rollback(value = false)
@RunWith(SpringRunner.class)
public class judgeItem {

    @Autowired
    private itemJudgeServiceImp itemjudeserviceimp;

    @Test
    public void test(){
//        填写评价信息
        itemjudge judgeinfo = new itemjudge("好","物品服务都不错","[\"http://127.0.0.1:8080/image/download?name=22c663df-a0ea-4b43-8c07-df4002000f0a.jpg\"]",
                                            "2023-03-29 18:55:08","xidnjgndfi-asdnjkcnxv","i7885544","o1678168560949");
        JSONObject judge = (JSONObject) JSON.toJSON(judgeinfo);

        //修改属性名进行处理
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("itemJudgeRank","level"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("itemJudgeText","judgetext"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("itemJudgePic","judgepic"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("itemJudgeTime","judgetime"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("userIdForJudge","userid"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("itemIdForJudge","itemid"));
        judge = (JSONObject) JSON.parse(JSON.toJSONString(judge).replace("orderIdForJudge","orderid"));
        System.out.println(judge);
        boolean result = itemjudeserviceimp.itemJudge(judge);
        System.out.println(result);

    }

}
